Skip to content

feat(utils): add logger#23

Merged
maitamdev merged 1 commit intomainfrom
pair/logger
Mar 5, 2026
Merged

feat(utils): add logger#23
maitamdev merged 1 commit intomainfrom
pair/logger

Conversation

@maitamdev
Copy link
Owner

@maitamdev maitamdev commented Mar 5, 2026

Colored console logger with log levels for development.


Summary by cubic

Adds a lightweight logger with color-coded console output and four levels (debug, info, warn, error). It standardizes logs and hides debug messages outside development.

  • New Features
    • New utils/logger.ts exporting a logger singleton.
    • Methods: logger.debug/info/warn/error(message, data?).
    • Adds ISO time and level prefix; debug logs run only when import.meta.env.DEV is true.

Written for commit 7813004. Summary will update on new commits.

Summary by CodeRabbit

  • Chores
    • Added a new logging utility to the application with support for multiple log levels (debug, info, warn, error), timestamped message formatting, and environment-aware output control.

Co-authored-by: maitamgk <169973104+maitamgk@users.noreply.github.com>
@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dhv-guiding-light Building Building Preview, Comment Mar 5, 2026 4:12am

@maitamdev maitamdev merged commit 85345ee into main Mar 5, 2026
1 of 3 checks passed
@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3dda7b3a-5168-4c3d-ab3c-03326c892a5f

📥 Commits

Reviewing files that changed from the base of the PR and between f65a659 and 7813004.

📒 Files selected for processing (1)
  • src/utils/logger.ts

📝 Walkthrough

Walkthrough

A new application-wide logger utility is introduced in src/utils/logger.ts. It provides a singleton Logger instance with public methods (debug, info, warn, error) that format timestamped messages by level, apply color styling, and respect a development-mode environment variable to suppress debug logs in non-development environments.

Changes

Cohort / File(s) Summary
Logger Utility
src/utils/logger.ts
New logger utility with public methods (debug, info, warn, error), color-coded output by level, timestamping, and DEV mode toggle to disable debug logs outside development.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A logger hops into the fray,
With colors bright and logs all day,
In debug mode it tells its tales,
Timestamps mark where truth prevails!
One singleton to rule them all,

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pair/logger

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/utils/logger.ts">

<violation number="1" location="src/utils/logger.ts:12">
P2: `isDev` falls back to `true`, which can unintentionally enable debug logs outside development when env metadata is unavailable.</violation>

<violation number="2" location="src/utils/logger.ts:18">
P2: Falsy payload values are silently dropped because `data` is checked with truthiness instead of `undefined` presence.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

};

class Logger {
private isDev = import.meta.env?.DEV ?? true;
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: isDev falls back to true, which can unintentionally enable debug logs outside development when env metadata is unavailable.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/logger.ts, line 12:

<comment>`isDev` falls back to `true`, which can unintentionally enable debug logs outside development when env metadata is unavailable.</comment>

<file context>
@@ -0,0 +1,28 @@
+};
+
+class Logger {
+  private isDev = import.meta.env?.DEV ?? true;
+
+  private log(level: LogLevel, message: string, data?: unknown): void {
</file context>
Suggested change
private isDev = import.meta.env?.DEV ?? true;
private isDev = import.meta.env?.DEV ?? false;
Fix with Cubic

if (!this.isDev && level === 'debug') return;
const timestamp = new Date().toISOString().slice(11, 23);
const prefix = '[' + timestamp + '] [' + level.toUpperCase() + ']';
if (data) { console.log('%c' + prefix + ' ' + message, LOG_COLORS[level], data); }
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Falsy payload values are silently dropped because data is checked with truthiness instead of undefined presence.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/utils/logger.ts, line 18:

<comment>Falsy payload values are silently dropped because `data` is checked with truthiness instead of `undefined` presence.</comment>

<file context>
@@ -0,0 +1,28 @@
+    if (!this.isDev && level === 'debug') return;
+    const timestamp = new Date().toISOString().slice(11, 23);
+    const prefix = '[' + timestamp + '] [' + level.toUpperCase() + ']';
+    if (data) { console.log('%c' + prefix + ' ' + message, LOG_COLORS[level], data); }
+    else { console.log('%c' + prefix + ' ' + message, LOG_COLORS[level]); }
+  }
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant